package com.riteny.token.helper.entity;

import lombok.Data;
import net.sf.json.JSONObject;

import java.util.List;

/**
 * @author Riteny
 * 2020/9/16  14:08
 */
@Data
public class UserTokenInformation {

    private String clientId;

    private String username;

    private List<String> resourceIds;

    private List<String> scopes;

    private List<String> authorities;

    private Boolean active;

    private Long expired;

    public UserTokenInformation() {
    }

    public UserTokenInformation(JSONObject jsonObject) {
        setClientId(jsonObject.optString("client_id"));
        setResourceIds(jsonObject.optJSONArray("aud"));
        setScopes(jsonObject.optJSONArray("scope"));
        setAuthorities(jsonObject.optJSONArray("authorities"));
        setUsername(jsonObject.optString("user_name"));
        setActive(jsonObject.optBoolean("active"));
        setExpired(jsonObject.optLong("exp"));
    }
}
